package Athena::Engine::Balance;

use strict;
use vars qw(@ISA);

use Athena::Connection;
use Athena::Engine;
use Exporter;

@ISA=qw(Athena::Engine);

sub new {
    # Get the class name
  my $stInvocant = shift(@_);
  my $stClass = ref($stInvocant) || $stInvocant;
  my $rSelf = $stClass->SUPER::new(@_);
  bless($rSelf, $stClass);
  $rSelf->{farms} = undef;
  return $rSelf;
}

sub refresh {
  my $rSelf = shift(@_);
  my $cConn = $rSelf->{connection};
  my @arOrderedFarms = sort(keys(%{$rSelf->{farms}}));
  my $stGetList = join(",", @arOrderedFarms);
  my $stFarmsBal = $cConn->httpGet($cConn->getUrl().'/balance/?'.$stGetList);
  my @arFarmsBal = split(/\n/, $stFarmsBal);
  my $stFarmBal;
  foreach $stFarmBal (@arFarmsBal) {
    my $stFarm = shift(@arOrderedFarms);
    $rSelf->{farms}->{$stFarm} = $stFarmBal;
  }
}

sub farmAdd {
  my $rSelf = shift(@_);
  my @arFarms = (@_);
  my $stFarm;
  foreach $stFarm (@arFarms) {
    $rSelf->{farms}->{$stFarm} = 0;
  }
}

1;
